package xjcs

import org.apache.commons.pool2.impl.GenericObjectPoolConfig
import redis.clients.jedis.JedisPool


object RedisClient extends Serializable {
    val redisHost = "localhost"
    val redisPort = 6379
    val redisTimeout = 30000
     val maxTotal=10000

  val poolConfig = new GenericObjectPoolConfig()
    poolConfig.setMaxTotal(maxTotal)
    poolConfig.setMinIdle(0)
    poolConfig.setMaxIdle(150)
    lazy val pool = new JedisPool(poolConfig, redisHost, redisPort, redisTimeout)

    lazy val hook = new Thread {
      override def run(): Unit = {
        println("Execute hook thread: " + this)
        pool.destroy()

      }
    }
    sys.addShutdownHook(hook.run())
  }

